Skip to content

feat(manifest): add socket.json reachability settings for the build tools - #1728

Open
Jeppe Fredsgaard Blaabjerg (jfblaa) wants to merge 6 commits into
jfblaa/facts-3-delete-scriptsfrom
jfblaa/facts-4-reachability-settings
Open

Jeppe Fredsgaard Blaabjerg (jfblaa) wants to merge 6 commits into
jfblaa/facts-3-delete-scriptsfrom
jfblaa/facts-4-reachability-settings

Conversation

@jfblaa

@jfblaa Jeppe Fredsgaard Blaabjerg (jfblaa) commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Heads up, reviewer

Reachability analysis can use different settings than sbom generation, e.g. analyse against a different java/dotnet runtime.
Additionally, customers may want to build their projects for reachability analysis, but not when just generating sboms.
This PR adds reachability settings to socket.json to help configure such properties.


LLM Description written by Claude Code:claude-opus-5-5

A build tool's socket.json section, and a build's own builds entry, take a reachability object that reachability scans send to Coana with each build root's request: whether to compile the project before the analysis, and the JDK or .NET runtime the analysis assumes.

Merges with the stack. The Coana release it needs is pinned on v1.x since #1762.

Settings
  • build: "compile" builds the project first, and a failed build fails the scan; "none" or unset analyses it unbuilt.
  • javaHome (Maven, Gradle, sbt): the JDK the analysis takes the program to run on, passed as written; unset, the build's own JDK.
  • runtimeVersion (.NET): the runtime a framework-dependent build's analysis starts on; major.minor takes its latest installed patch, major.minor.patch[-prerelease] exactly that runtime.
Cascade and validation
  • Each field cascades on its own, a build's builds entry last; null clears an inherited value.
  • Only reachability scans that generate facts read them, for the build tools they run, so an invalid value never stops another command.
  • An invalid value or a field the tool doesn't take fails the scan before any build runs, naming the socket.json and setting.
Stack
  1. fix: keep the API token and settings socket-cli passes Coana out of the build tools it runs #1725: Keep the Socket API token out of the tools Coana runs (merged)
  2. feat(manifest): generate Socket facts with Coana #1726: Generate Socket facts with Coana
  3. refactor(manifest): delete socket-cli's build-tool scripts and facts assembly #1727: Delete socket-cli's build-tool scripts and facts assembly (internal)
  4. feat(manifest): add socket.json reachability settings for the build tools #1728: socket.json reachability settings for the build tools (this PR)
  5. feat(manifest): ask for the reachability settings in the setup wizards #1729: Reachability settings in the setup wizards
  6. refactor: follow-ups to generating Socket facts with Coana #1733: Follow-ups (draft)

Changelog

In CHANGELOG.md under [Unreleased]:

Added

  • Tune reachability per build tool in socket.json: reachability.build compiles the project before the analysis, reachability.javaHome (Maven, Gradle, sbt) sets the JDK the analysis assumes, and reachability.runtimeVersion (.NET) sets the runtime it starts on.

🤖 Generated with Claude Code

@cursor

cursor Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes reachability scan behavior and Coana request payloads; misconfiguration can fail scans early or alter analysis JDK/runtime/compile behavior, but scope is manifest configuration rather than auth or data handling.

Overview
Adds reachability blocks on each JVM/.NET manifest tool section and per-builds entry so reachability scans can differ from plain SBOM generation: whether Coana compiles first (build: "compile" vs "none"), which JDK the analysis assumes (javaHome for Maven/Gradle/sbt), and which .NET runtime to start on (runtimeVersion).

Settings cascade field-by-field (with null clearing inherited values); mergeBuildToolDefaults merges nested reachability when chaining socket.json files. Resolution and validation run in build-root-config (tool-specific fields, .NET SemVer-style runtime strings) and fail the scan before any build when invalid, naming the offending socket.json or build entry.

Only reachability scans (workDir.withFiles) read and forward these values through generateRecursiveManifests, generateAutoManifest, and convertDotnetToFacts into the Coana generate-socket-facts request (run-manifest-facts). Skipped tools (disabled, Gradle/sbt facts: false) are not validated. Docs and changelog describe the new fields.

Reviewed by Cursor Bugbot for commit 4e3d59e. Configure here.

@jfblaa
Jeppe Fredsgaard Blaabjerg (jfblaa) force-pushed the jfblaa/facts-4-reachability-settings branch 2 times, most recently from 202fa9b to c66275d Compare November 20, 2026 18:14
@jfblaa
Jeppe Fredsgaard Blaabjerg (jfblaa) force-pushed the jfblaa/facts-4-reachability-settings branch 2 times, most recently from a718c85 to 088c34c Compare November 25, 2026 09:10

@mtorp Martin Torp (mtorp) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left seven source-comment notes on the changes to reachability settings. They cover wording and duplicated explanations.

// auto/gradle/etc. facts:false has no pom-mode equivalent here (facts-only),
// so it skips too.
function getSkipReason(
// Only Gradle and sbt take `facts: false`, which generates pom files instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMT-26 Nit, the condition below already lists Gradle and sbt. Could we drop this extra sentence? The preceding comment explains the part specific to recursive discovery, which skips a build configured for POM mode.

Comment on lines +40 to +41
// The cascaded `reachability` settings, checked in every socket.json that
// sets them; throws an InputError naming an invalid one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMT-27 Wording nit. Could we give the error behavior its own sentence?

Suggested change
// The cascaded `reachability` settings, checked in every socket.json that
// sets them; throws an InputError naming an invalid one.
// Checks reachability settings in every socket.json that supplies them.
// An invalid setting raises an InputError naming the file and field.

Comment on lines +337 to +338
// Why `tool`'s reachability `field` cannot be `value`, as the rest of a
// sentence about it; undefined when it can.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMT-28 Wording nit. Could we separate the error text from the success result?

Suggested change
// Why `tool`'s reachability `field` cannot be `value`, as the rest of a
// sentence about it; undefined when it can.
// Returns a phrase explaining why the tool rejects this field value.
// Returns undefined for a valid value.

Comment on lines +86 to +87
// What a reachability scan's analysis reads of a build's settings; only set
// fields are sent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMT-29 Wording nit. Could we say which settings reach Coana in one sentence?

Suggested change
// What a reachability scan's analysis reads of a build's settings; only set
// fields are sent.
// A reachability scan sends Coana only the settings configured for this build.

Comment thread src/utils/socket-json.mts Outdated

export const REACHABILITY_BUILDS = ['compile', 'none'] as const

// Whether a reachability analysis builds the project first; unset is "none".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMT-30 Wording nit. Could we give the default build mode its own sentence?

Suggested change
// Whether a reachability analysis builds the project first; unset is "none".
// Controls whether reachability analysis builds the project first. Defaults to "none".

Comment thread src/utils/socket-json.mts Outdated
// Whether a reachability analysis builds the project first; unset is "none".
export type ReachabilityBuild = (typeof REACHABILITY_BUILDS)[number]

// Read only by reachability scans; a null field clears an inherited value.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMT-31 Wording nit. Could we state the meaning of null in its own sentence?

Suggested change
// Read only by reachability scans; a null field clears an inherited value.
// Only reachability scans read these settings. A null field clears its inherited value.

return displayPath(path.join(dir, SOCKET_JSON))
}

// The `reachability` settings of `tool` in one socket.json, checked.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMT-32 Nit, the function name already tells me which settings this reads. Could we drop the comment, or document that an invalid value throws an error naming the file?

A build tool's socket.json section takes a `reachability` object, which
reachability scans send to Coana with each build root's request:

- `build`: "compile" builds the project before the analysis, "none" or
  unset analyses it unbuilt;
- `javaHome`, Maven, Gradle and sbt: the JDK the analysis takes the
  program to run on, as written;
- `runtimeVersion`, .NET: the runtime a framework-dependent build's
  analysis starts on, as major.minor or major.minor.patch[-prerelease].

Each field cascades on its own, a build's own `builds` entry last, and
null clears an inherited one. Only a reachability scan reads them, for the
build tools it runs, so an invalid value never stops another command. It
checks them before any build runs and fails naming the socket.json and
setting, including a field the build tool does not take.
`socket scan create --reach --auto-manifest` read the reachability settings
only from the socket.json in the directory it scans, so a JDK or .NET
runtime set by a parent socket.json was dropped. It now cascades them from
every socket.json down to that directory, as `socket manifest` does, and a
null in a nearer file still clears an inherited value. An invalid setting in
any of those files fails the scan before a build runs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants